package Freya.base;
import java.util.Scanner;

public class scanner03 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        //定义变量，用于从键盘接收数据
        int i = 0;
        float f = 0.0f;
        System.out.println("请输入整数：");
        if (scanner.hasNextInt()){//输入的数据是否是整数
            i = scanner.nextInt();
            System.out.println("整数数据：" + i);
        }else{
            System.out.println("输入的不是整数数据！");
        }
        System.out.println("请输入小数：");
        if (scanner.hasNextFloat()){//输入的数据是否是小数
            f = scanner.nextFloat();
            System.out.println("小数数据：" + f);
        }else{
            System.out.println("输入的不是小数数据！");
        }
    }


//    scanner.close();
}
